import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		hasLogin: false,
		userInfo: null
	},
	mutations: {
		login(state, provider) {
			state.hasLogin = true;
			state.userInfo = {...provider};
		},
		logout(state) { 
			state.hasLogin = false;
			state.userInfo = null;
			uni.removeStorageSync('nickname');
			uni.removeStorageSync('headimg');
			uni.removeStorageSync('session_key');
			uni.removeStorageSync('openid');
			uni.removeStorageSync('token');
			uni.removeStorageSync('userInfo');
		}
	},
	actions: {
		
	}
})

export default store